﻿using HCQ2_Model.APPModel.ParamModel;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;

namespace HCQ2_Model
{
    public class ExperienceDetial
    {
        public int ed_id { get; set; }
        [Required(ErrorMessage = "er_id：体验记录主表id必填")]
        public int er_id { get; set; }
        [Required(ErrorMessage = "word：单词必填")]
        public string word { get; set; }
        [Required(ErrorMessage = "ed_status：状态必填")]
        public int ed_status { get; set; } = 1;
        [Required(ErrorMessage = "score：得分必填")]
        public decimal score { get; set; }
        public string in_date { get; set; }
        public int user_id { get; set; }

        public T_VRExperienceDetail ToEntity()
        {
            return new T_VRExperienceDetail
            {
                ed_id = this.ed_id,
                er_id = this.er_id,
                word = this.word,
                ed_status = (this.ed_status == 0) ? false : true,
                score = this.score,
                user_id = this.user_id,
                in_date = (this.in_date != null) ? DateTime.ParseExact(this.in_date, "yyyyMMddHHmmss", CultureInfo.CurrentCulture, DateTimeStyles.None) : DateTime.Now
            };
        }
    }

    public partial class T_VRExperienceDetail
    {
        public ExperienceDetial ToPOCO()
        {
            return new ExperienceDetial
            {
                ed_id = this.ed_id,
                er_id = this.er_id,
                word = this.word,
                ed_status = (this.ed_status) ? 1 : 0,
                score = this.score,
                user_id = this.user_id,
                in_date = this.in_date.ToString("yyyy-MM-dd HH:mm")
            };
        }
    }

    public class ExperienceDetialList: BaseAPI
    {
        [Required(ErrorMessage = "record：体验记录集合必填")]
        public List<ExperienceDetial> record { get; set; }
    }
}
